package com.example.shiyan02.model

import android.content.Context
import com.example.shiyan02.R

class ProgramModel {
    private val programAdvice = mapOf(
        R.string.computer_science to "计算机科学是研究计算机系统、算法和计算的学科。就业前景广阔，适合喜欢编程和数学的学生。",
        R.string.software_engineering to "软件工程注重软件开发的方法论和工程实践。适合注重代码质量和团队协作的学生。",
        R.string.artificial_intelligence to "人工智能研究智能机器的设计和应用。需要扎实的数学和编程基础，发展前景良好。",
        R.string.data_science to "数据科学结合统计学和计算机科学分析数据。在大数据时代需求旺盛，适合喜欢数据分析的学生。",
        R.string.cyber_security to "网络安全保护信息系统免受威胁。随着数字化发展，专业人才需求持续增长。"
    )

    fun getAdvice(programName: String, context: Context): String {
        return when (programName) {
            context.getString(R.string.computer_science) ->
                programAdvice[R.string.computer_science] ?: getDefaultAdvice(context)
            context.getString(R.string.software_engineering) ->
                programAdvice[R.string.software_engineering] ?: getDefaultAdvice(context)
            context.getString(R.string.artificial_intelligence) ->
                programAdvice[R.string.artificial_intelligence] ?: getDefaultAdvice(context)
            context.getString(R.string.data_science) ->
                programAdvice[R.string.data_science] ?: getDefaultAdvice(context)
            context.getString(R.string.cyber_security) ->
                programAdvice[R.string.cyber_security] ?: getDefaultAdvice(context)
            else -> context.getString(R.string.unknown_program_error)
        }
    }

    private fun getDefaultAdvice(context: Context): String {
        return context.getString(R.string.unknown_program_error)
    }

    fun getAvailablePrograms(context: Context): List<String> {
        return listOf(
            context.getString(R.string.computer_science),
            context.getString(R.string.software_engineering),
            context.getString(R.string.artificial_intelligence),
            context.getString(R.string.data_science),
            context.getString(R.string.cyber_security)
        )
    }
}